<?php
include_once 'config.php';
function login($username,$password,$DB_NAME){
	$db=new SQLiteDatabase($DB_NAME);
	$real_name= sqlite_escape_string($username);
	$real_passord = sqlite_escape_string($password);
	$md5_password = md5($real_passord);
	$result=$db->query("SELECT * FROM users where username='$real_name' and password='$md5_password'");
	$index =null;
	while($result->valid()) {
		$row=$result->current();
		return true;
	}
	return false;
}
if(login($_POST["myusername"],$_POST["mypassword"], $DB_NAME)){
	header("location:addstock.php");
}else{
	header("location:login.php"); 
}
?>